/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jl.tools.stkeditor.generate;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author LuHongjun
 */
public final class UnicodeCode implements Code{
  
  private final String oneline;
  public UnicodeCode(String oneline){
    this.oneline = oneline;
  }

  @Override
  public List<String> getCode() {
    List<String> l = new ArrayList<String>();
    for(int i=0;i<oneline.length();i++){
      l.addAll(getOneCharCode(i));
    }
    return l;
  }

  @Override
  public int getLength() {
    return  oneline.length() * 2;
  }

  private List<String> getOneCharCode(int i) {
    List<String> l = new ArrayList<String>();
    String temp = Integer.toHexString(oneline.codePointAt(i));
    while(temp.length() < 4){
      temp = "0" + temp;
    }
    temp = temp.toUpperCase();
    l.add(temp.substring(0, 2));
    l.add(temp.substring(2));
    return l;
  }
  
}
